#include #include #define BUTTON_PIN D8 #define NODE_2 2 #define NODE_3 3 // 🔴 REPLACE THIS with your actual Node 2 MAC uint8_t macNode2[] = {0x7C, 0x2C, 0x67, 0x64, 0xBA, 0xF8}; // ✅ Your Node 3 MAC (already correct) uint8_t macNode3[] = {0x58, 0xE6, 0xC5, 0x19, 0xB9, 0xBC}; typedef struct { int targetID; int command; } Message; Message msg; bool lastState = HIGH; void setup() { Serial.begin(115200); pinMode(BUTTON_PIN, INPUT_PULLUP); WiFi.mode(WIFI_STA); if (esp_now_init() != ESP_OK) { Serial.println("ESP-NOW init failed"); return; } // Add Node 2 esp_now_peer_info_t peer2 = {}; memcpy(peer2.peer_addr, macNode2, 6); peer2.channel = 0; peer2.encrypt = false; esp_now_add_peer(&peer2); // Add Node 3 esp_now_peer_info_t peer3 = {}; memcpy(peer3.peer_addr, macNode3, 6); peer3.channel = 0; peer3.encrypt = false; esp_now_add_peer(&peer3); Serial.println("Master ready"); } void loop() { bool currentState = digitalRead(BUTTON_PIN); if (lastState == HIGH && currentState == LOW) { Serial.println("Sending to Node 2"); msg.targetID = NODE_2; msg.command = 1; esp_now_send(macNode2, (uint8_t *)&msg, sizeof(msg)); Serial.println("Sending to Node 3"); msg.targetID = NODE_3; msg.command = 1; esp_now_send(macNode3, (uint8_t *)&msg, sizeof(msg)); delay(300); } lastState = currentState; }